﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="word.aspx.cs" Inherits="www.pages.word.word" ValidateRequest="false" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../../plugins/layer/theme/default/layer.css" rel="stylesheet" />
    <link href="../../css/lanai-ui.min.css" rel="stylesheet" />
    <style type="text/css">
        .tag {
            position: relative;
            margin-top: 5px;
            margin-right: 5px;
            float: left;
        }
    </style>
</head>
<body>
    <section class="content">
        <form id="form1" runat="server">
            <div class="row">
                <div class="col-sm-8">
                    <div class="box box-default no-border no-shadow">
                        <div class="box-body no-pad-top">
                            <div class="row">
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label>标题(<span class="text-red">*</span>)</label>
                                        <input id="txt_doc_name" type="text" class="form-control" runat="server" />
                                    </div>
                                </div>
                                <div class="col-sm-8">
                                    <div class="form-group">
                                        <label>描述</label>

                                        <div class="input-group">
                                            <input id="txt_doc_comment" type="text" class="form-control" runat="server" />
                                            <div class="input-group-btn">
                                                <button id="btnsave" type="button" class="btn btn-default">保存</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <textarea id="editor1" name="editor1" rows="20" cols="80" runat="server">
                                   Word内容模板.
                            </textarea>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label>检索标签</label>
                        <div class="input-group">
                            <input type="text" class="form-control" id="txt_Tag" placeholder="请输入标签名称" runat="server" />
                            <div class="input-group-btn">
                                <asp:LinkButton ID="btnQueryTag" runat="server" CssClass="btn btn-default no-radius" OnClick="btnQueryTag_Click"><i class="fa fa-search"></i></asp:LinkButton>
                                <a href="#" id="btnAddTag" class="btn btn-default no-radius"><i class="fa fa-plus"></i></a>
                            </div>
                        </div>
                    </div>
                    <asp:Repeater ID="list_tags" runat="server">
                        <HeaderTemplate>
                            <table class="table table-bordered table-striped table-hover text-center">
                                <thead>
                                    <tr>
                                        <th style="width: 60px">序号</th>
                                        <th>名称</th>
                                        <th style="width: 80px">类型</th>
                                        <th style="width: 200px">描述</th>
                                        <th style="width: 120px">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td><%#Container.ItemIndex+1 %></td>
                                <td style="text-align: left"><%#Eval("tag_name") %></td>
                                <td><%#Core.Util.getTagStatusName(Eval("tag_type").ToString()) %></td>
                                <td style="text-align: left"><%#Eval("tag_comment") %></td>
                                <td><a href="#" name="useTag" class="btn btn-sm btn-success" data-name="<%#Eval("tag_name") %>">应用</a></td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </tbody>
                    </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </div>
            </div>
            <input type="hidden" id="hid_Project" runat="server" />
            <input type="hidden" id="hid_document" runat="server" />
        </form>
    </section>
    <script src="../../js/jquery.min.js"></script>
    <script src="../../plugins/layer/layer.js"></script>
    <script src="../../plugins/ckeditor/ckeditor.js"></script>
    <script src="../../plugins/ckfinder/ckfinder.js"></script>
    <script src="../../js/lanai-ui.min.js"></script>
    <script type="text/javascript">
        $(function () {
            var height = $(document).height() - 220;
            var masterEditor = CKEDITOR.replace('editor1', { height: height });
            CKFinder.setupCKEditor(masterEditor, '../../plugins/ckfinder/');

            $("#btnsave").click(function () {
                var id = $("#hid_document").val();
                var name = $("#txt_doc_name").val();
                var comment = $("#txt_doc_comment").val();
                var template = masterEditor.document.getBody().getHtml();
                if (name == "") {
                    parent.layer.alert("请输入文档名称", { title: '系统提示', icon: 2 });
                    return;
                }

                parent.doSaveDocument(id, name, comment, template);
            });

            function init_click_events(ele) {
                ele.each(function () {
                    $(this).on('click', function () {
                        masterEditor.insertHtml("[#" + $.trim($(this).data("name")) + "#]");
                    });
                });
            }
            init_click_events($("[name='useTag']"));

            $("#btnAddTag").click(function () {
                parent.edit_tag("0");
            });
        });
    </script>
</body>
</html>
